home *** CD-ROM | disk | FTP | other *** search
- /* © 1988, Bowers Development Corp. */
- /* Cursors.c */
-
- #include "Globals.h"
- #include "ResourceDefs.h"
-
- #include "Cursors.h"
-
- RgnHandle cursorRgn;
- CursHandle watch;
-
-
- CursHandle iBeam;
-
- #define TopLeft(aRect) (* (Point *) &(aRect).top)
- #define BotRight(aRect) (* (Point *) &(aRect).bottom)
-
- /*----------*/
- void LoadCursors ()
- {
- watch = GetCursor (watchCursor);
- iBeam = GetCursor (iBeamCursor);
-
- cursorRgn = NewRgn ();
-
- InitCursor ();
- } /*LoadCursors*/
-
- /*----------*/
- void GlobalRectRgn (RgnHandle destRegion,
- Rect sourceRect);
- void GlobalRectRgn (destRegion, sourceRect)
- RgnHandle destRegion;
- Rect sourceRect;
- {
- LocalToGlobal (&TopLeft (sourceRect));
- LocalToGlobal (&BotRight (sourceRect));
- RectRgn (destRegion, &sourceRect);
- } /*GlobalRectRgn*/
-
- /*----------*/
- void ShapeCursor ()
- {
- WindowPtr front;
- WindowPeek frontPeek;
- RgnHandle arrowRgn;
- RgnHandle iBeamRgn;
- Point mousePoint;
- Rect textRect;
-
- front = FrontWindow ();
- frontPeek = (WindowPeek) front;
- if (inBackground) {
- /*let foreground set cursor*/
- } else if ((front != nil) && (frontPeek->windowKind < 0)) {
- /*let da set its own cursor*/
- } else {
- arrowRgn = NewRgn ();
- iBeamRgn = NewRgn ();
- RectRgn (arrowRgn, &screenBits.bounds);
- mousePoint = curEvent.where;
- if (front == nil) {
- /*arrow*/
- } else if (front == curWindow) {
- SetPort (curWindow); /*for local-to-global*/
- if (cur->text != nil) {
- textRect = (**(cur->text)).viewRect;
- GlobalRectRgn (iBeamRgn, textRect);
- }
- DiffRgn (arrowRgn, iBeamRgn, arrowRgn);
- }
- if (PtInRgn (mousePoint, iBeamRgn)) {
- SetCursor (&(**iBeam));
- CopyRgn (iBeamRgn, cursorRgn);
- } else {
- SetCursor (&arrow);
- CopyRgn (arrowRgn, cursorRgn);
- }
- DisposeRgn (arrowRgn);
- DisposeRgn (iBeamRgn);
- }
- } /*ShapeCursor*/
-